const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    info: {},
    list: {},
    member_id:"",
    invite_code:'',
    yz_basic_info:{},
    profitData:{},
    vanTab:[{
      title:'分享奖励',
      id:1
    },{
      title:'单单返利',
      id:2
    }],
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
    this.setData({
      yz_basic_info:wx.getStorageSync('yz_basic_info'),
      point : wx.getStorageSync('integral'),
      balance:wx.getStorageSync('balance'),
      member_id:wx.getStorageSync("yz_uid"),
      invite_code:wx.getStorageSync("invite_code")
    })
    this.getData();
    this.getProfitData();
  },
  getData() {
    let baseUrl = app.getNetAddresss("plugin.newcomer-fission.frontend.controllers.center.index");
    app._getNetWork({
      url: baseUrl,
      success: (respone) => {
        let { data, msg, result } = respone.data;
        if (result !== 1) {
          wx.showToast({
            title: msg,
          });
          return false;
        } else {
          this.setData({
            info: data.info,
            list: data.list,
          });
        }
      },
    });
  },
  getProfitData() {
    let baseUrl = app.getNetAddresss("plugin.newcomer-fission.frontend.controllers.list.get-statistics-pool-list");
    let that = this;
    app._getNetWork({
      url: baseUrl,
      success: (respone) => {
        let { data, msg, result } = respone.data;
        if (result !== 1) {
          wx.showToast({
            title: msg,
          });
          return false;
        } else {
          that.setData({
            profitData:data
          });
          console.log(that.data.profitData)
        }
      },
    });
  },
  goRewardRecord() {
    wx.navigateTo({
      url: "/packageI/newcomer_fission/newcomer_reward/newcomer_reward",
    });
  },
  goRewardProfit() {
    wx.navigateTo({
      url: "/packageI/newcomer_fission/newcomer_profit/newcomer_profit",
    });
  },
  copybtn(e) {
    let inviteCode = e.target.dataset.num;
    wx.setClipboardData({
      data: inviteCode ? inviteCode : "",
      success(res) {
        wx.showToast({
          icon: "none",
          title: "复制成功",
          duration: 1000,
        });
      },
    });
  },
});
